<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: class.microdata.php 135 2013-09-22 07:30:55Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 135 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 07:30:55 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright © since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	© 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	© 2002-2003 osCommerce - www.oscommerce.com
* 	© 2003     nextcommerce - www.nextcommerce.org
* 	© 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

class microdata {
	
	function ItemScope($val) {
		switch($val) {
			case 'product': # Produkt
				return ' itemscope itemtype="http://schema.org/Product"';
				break;
			
			case 'offer': # Preisinfos
				return ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"';
				break;
			
			case 'breadcrumb':
				return ' itemscope itemtype="http://data-vocabulary.org/Breadcrumb"';
				break;

			case 'review': # einzelne Bewertung - komplett
				return ' itemprop="reviews" itemscope itemtype="http://schema.org/Review"';
				break;
				
			case 'rating': # einzelne Bewertung - Werte
				return ' itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating"';
				break;
		}
	}
	
	function ItemProp($val, $def = '') {
		switch($val) {
			case 'offer': # Produktlink
				return ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"';
				break;
				
			case 'name': # Preis
				return ' itemprop="name"';
				break;
				
			case 'desc': # Beschreibung
				return ' itemprop="description"';
				break;
			
			case 'image': # Bild
				return ' itemprop="image"';
				break;
			
			case 'identifier_mpn':
				return ' itemprop="identifier" content="mpn:'.$def.'"';
				break;
			
			case 'identifier_ean':
				return ' itemprop="identifier" content="ean:'.$def.'"';
				break;
			
			case 'identifier_isbn':
				return ' itemprop="identifier" content="isbn:'.$def.'"';
				break;
			
			case 'price': # Produktpreis
				return ' itemprop="price"';
				break;
			
			case 'aggregaterating_main_1':
				return '<span itemprop="ratingValue">'.$def.'</span>/5';
				break;
			
			case 'aggregaterating_main_2':
				return ' bei <span itemprop="reviewCount">'.$def.'</span> ';
				break;
			
			case 'rating_amount': # einzelne Bewertung - Werte
				return '<meta itemprop="worstRating" content="1"><span itemprop="ratingValue">'.$def.'</span>/<span itemprop="bestRating">5</span>';
				break;
			
			case 'availability': # Produktlink
				return '<link itemprop="availability" href="http://schema.org/InStock" />';
				break;
				
			case 'aggregaterating': # gesamt Bewertungen
				return ' itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"';
				break;
				
			case 'author': # Author
				return ' itemprop="author"';
				break;
				
			case 'date_puplished':
				return '<meta itemprop="datePublished" content="'.substr($def, 0, 10).'">';
				break;
				
			case 'breadcrumb';
				return array('url' => ' itemprop="url"', 'title' => ' itemprop="title"');
				break;
		}
	}
}